﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using NetBay.Core.BusinessEntities;

namespace Rio.Framework.Pages.AppCode.Models
{
    public class MessageFlowDisp : INotifyPropertyChanged
    {
        #region Fields

        /// <summary>
        /// Get or set the last message action date
        /// </summary>
        private bool m_bSendAlertByEmail;

        /// <summary>
        /// 
        /// </summary>
        private DateTime m_dtExpedition;

        /// <summary>
        /// Get or set the last message action date
        /// </summary>
        private DateTime m_dtLastActionDate;

        /// <summary>
        /// Get or set the last message read date
        /// </summary>
        private DateTime m_dtLastReadDate;

        /// <summary>
        /// 
        /// </summary>
        private int m_iMyDocEtat;

        /// <summary>
        /// 
        /// </summary>
        private long m_lGroupId;

        /// <summary>
        /// 
        /// </summary>
        private long m_lIdentifier;

        /// <summary>
        /// 
        /// </summary>
        private List<Document> m_lMessageFlowDocuments;

        /// <summary>
        /// 
        /// </summary>
        private long m_lrgu_id;

        /// <summary>
        /// 
        /// </summary>
        private User m_oEmetteur;

        /// <summary>
        /// 
        /// </summary>
        private string m_sChrono;

        /// <summary>
        /// 
        /// </summary>
        private string m_sDestinataire;

        /// <summary>
        /// 
        /// </summary>
        private string m_sDestinataireList;

        /// <summary>
        /// 
        /// </summary>
        private string m_sMemo;

        /// <summary>
        /// 
        /// </summary>
        private string m_sObjet;

        #endregion Fields

        #region Constructors

        public MessageFlowDisp()
        {
        }

        /// <summary>
        /// Constructor initiating a new MessageFlowDisp from a MessageFlow object
        /// </summary>
        /// <param name="p_oMsg"></param>
        public MessageFlowDisp(MessageFlow p_oMsg)
        {
            List<Document> l_oDocumentList = new List<Document>();
            Identifier = p_oMsg.Identifier;
            Emetteur = p_oMsg.Emetteur;
            if (p_oMsg.DocumentList != null && p_oMsg.DocumentList.Count > 0)
            {
                foreach (Document l_oDoc in p_oMsg.DocumentList)
                {
                    l_oDocumentList.Add(l_oDoc);
                }
            }
            DocumentList = l_oDocumentList;
            DestinataireList = p_oMsg.DestinataireList;
            Destinataire = p_oMsg.Destinataire;
            GroupId = p_oMsg.GroupId;
            RguId = p_oMsg.RguId;
            Expedition = p_oMsg.Expedition;
            Objet = p_oMsg.Objet;
            Memo = p_oMsg.Memo;
            Chrono = p_oMsg.Chrono;
            MyDocEtat = p_oMsg.MyDocEtat;
            LastActionDate = p_oMsg.LastActionDate;
            LastReadDate = p_oMsg.LastReadDate;
            SendAlertByEmail = p_oMsg.SendAlertByEmail;
        }

        #endregion Constructors

        #region Events

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion Events

        #region Properties

        public string Chrono
        {
            get { return m_sChrono; }
            set { m_sChrono = value; }
        }

        public string Destinataire
        {
            get { return m_sDestinataire; }
            set { m_sDestinataire = value; }
        }

        public string DestinataireList
        {
            get { return m_sDestinataireList; }
            set { m_sDestinataireList = value; }
        }

        public List<Document> DocumentList
        {
            get { return m_lMessageFlowDocuments; }
            set
            {
                m_lMessageFlowDocuments = value;

            }
        }

        public User Emetteur
        {
            get { return m_oEmetteur; }
            set
            {
                m_oEmetteur = value;
            }
        }

        public DateTime Expedition
        {
            get { return m_dtExpedition; }
            set { m_dtExpedition = value; }
        }

        public long GroupId
        {
            get { return m_lGroupId; }
            set { m_lGroupId = value; }
        }

        public long Identifier
        {
            get { return m_lIdentifier; }
            set { m_lIdentifier = value; }
        }

        public DateTime LastActionDate
        {
            get { return m_dtLastActionDate; }
            set
            {
                m_dtLastActionDate = value;
                OnNotifyPropertyChanged("LastActionDate");
            }
        }

        public DateTime LastReadDate
        {
            get { return m_dtLastReadDate; }
            set
            {
                m_dtLastReadDate = value;
                OnNotifyPropertyChanged("LastReadDate");
            }
        }

        public string Memo
        {
            get { return m_sMemo; }
            set { m_sMemo = value; }
        }

        public int MyDocEtat
        {
            get { return m_iMyDocEtat; }
            set
            {
                m_iMyDocEtat = value;
                OnNotifyPropertyChanged("MyDocEtat");
            }
        }

        public string Objet
        {
            get { return m_sObjet; }
            set { m_sObjet = value; }
        }

        public long RguId
        {
            get { return m_lrgu_id; }
            set { m_lrgu_id = value; }
        }

        public bool SendAlertByEmail
        {
            get { return m_bSendAlertByEmail; }
            set
            {
                m_bSendAlertByEmail = value;
                OnNotifyPropertyChanged("SendAlertByEmail");
            }
        }

        #endregion Properties

        #region Methods

        private void OnNotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion Methods
    }
}